package com.sun.config;

import android.app.Application;

import com.sun.dailyprj.BuildConfig;
import com.sun.dailyprj.util.Logger;

import java.util.HashMap;

public class AppConfig extends ExternalConfigFile implements ConfigVals,IAppConfig {
	
	Application a;
	public AppConfig(String fileName, Application app, LogConfig lc) {
		super(fileName, lc, app);
		a = app;
	}

	public static class LogConfig{
		public String name;
		public int level;
		public int maxFiles;
		public boolean enabled;
	}

	@Override
	protected void debugKeySet(HashMap<String, String> cfgData){
		/*  only connect test server, normally off */
//		cfgData.put(KEY_CFG_SWITCH, "true");
//		cfgData.put(ATTR_IMEI, "354914050426240");
//		cfgData.put(ATTR_MF, "Micromax");
//		cfgData.put(ATTR_MODEL, "Micromax Q335");
//		cfgData.put(ATTR_FW_VER, "MMX_Q335_SW_V8.0.2_HW_V1.2.0_04212015");
	}
	
	@Override
	protected void onFindCfgFile(boolean isFound, Object lc) {
		Logger.debug("find cfg:" + isFound);
		LogConfig logCfg = (LogConfig)lc;
		if(!isFound && !BuildConfig.DEBUG){
			logCfg.enabled = false;
		}else{
			logCfg.enabled = true;
		}
	}
	
	@Override
	public String getStrConfig(String key, String defVal){
		return Convert.toString(getCfg(key, defVal));
	}
	
	@Override
	public boolean getBoolConfig(String key, boolean defVal){
		return Convert.toBoolean(getCfg(key, defVal));
	}
	
	@Override
	public int getIntConfig(String key, int defVal){
		return Convert.toInteger(getCfg(key, defVal));
	}
	@Override
	public boolean debugIsOn(){
		return debugModeOpen();
	}
	
	/********************************************
	 * Application Attrbuite Setting
	 *******************************************/
//	@Override
//	public boolean customTitleLogo(){
//		return BuildConfig.CUSTOM_LOGO;
//	}
//
//	@Override
//	public String getDevChannel(){
//		return BuildConfig.FOTA_CHANNEL;
//	}
//
//	@Override
//	public String getApiUriBase(){
//		return new String(Base64.decode(BuildConfig.FOTA_URI_BASE, Base64.DEFAULT));
//	}
//
//	@Override
//	public boolean customerReport(){
//		return BuildConfig.CUSTOMER_REPORT;
//	}
//
//	@Override
//	public String getPushUrlBase(){
//		return BuildConfig.PUSH_URL_BASE.isEmpty() ? null : BuildConfig.PUSH_URL_BASE;
//	}
//
//	@Override
//	public boolean isOnlyWifi(){
//		return BuildConfig.ONLY_WIFI;
//	}
//
//	@Override
//	public boolean pushConfigurable() {
//		return BuildConfig.PUSH_SWITCH;
//	}
//
//	@Override
//	public boolean showNotificationDialog() {
//		return BuildConfig.SHOW_NOTIFICATION_SWITCH_DIALOG;
//	}
//
//	@Override
//	public boolean skipEula() {
//		return BuildConfig.SKIP_EULA;
//	}
//
//	@Override
//	public String getEULAUrl() {
//		return BuildConfig.EULA_URL;
//	}
}
